#include <iostream>
#include <set>
using namespace std;
int n,k,ans;
multiset<int>q;
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;++i){
		int x;cin>>x;
		q.insert(x);
	}
	for(set<int>::iterator it=q.begin();it!=q.end();++it)
		ans+=q.count(*it+k);
	cout<<ans<<endl;
	return 0;
}
